package com.qxt.prize.forms;

import com.qxt.prize.models.Prize;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import top.moirae.core.AbstractOption;

import java.math.BigDecimal;
import java.time.LocalDateTime;


public interface PrizeForm {

    @Data
    class Create {
        @NotBlank(message = "奖品名称不能为空")
        private String name; // 奖品名称
        @NotNull(message = "奖品价值不能为空")
        private BigDecimal value; // 奖品价值
        private Long quantity; // 奖品库存数量
        @NotNull(message = "奖品类型不能为空")
        private Prize.Type type; // 奖品类型
        @NotBlank(message = "奖品展示资源不能为空")
        private String cover; // 奖品展示资源

        private String description;

        public AbstractOption<String> getDescription() {
            return AbstractOption.apply(description);
        }
        public AbstractOption<Long> getQuantity() {
            return AbstractOption.apply(quantity);
        }
    }

    @Data
    class Search {
        private Long id;
        private String name; // 奖品名称
        private String type; // 奖品类型
        private Boolean isPublish; // 是否发布

        public AbstractOption<Long> getId() {
            return AbstractOption.apply(id);
        }

        public AbstractOption<String> getName() {
            return AbstractOption.apply(name);
        }

        public AbstractOption<String> getType() {
            return AbstractOption.apply(type);
        }
        public AbstractOption<Boolean> isPublish() {
            return AbstractOption.apply(isPublish);
        }

    }

    @Data
    class Update {
        private Long id;
        @NotBlank(message = "奖品名称不能为空")
        private String name; // 奖品名称
        @NotNull(message = "奖品价值不能为空")
        private BigDecimal value; // 奖品价值
        private Long quantity; // 奖品库存数量
        @NotNull(message = "奖品类型不能为空")
        private Prize.Type type; // 奖品类型
        @NotBlank(message = "奖品展示资源不能为空")
        private String cover; // 奖品展示资源
        private LocalDateTime publishAt; // 发布时间

        private String description;

        public AbstractOption<String> getDescription() {
            return AbstractOption.apply(description);
        }
        public AbstractOption<LocalDateTime> getPublishAt() {
            return AbstractOption.apply(publishAt);
        }
        public AbstractOption<Long> getQuantity() {
            return AbstractOption.apply(quantity);
        }

    }

}

